﻿using DomainService.IService.MatchFormula;
using DomainService.IService.Sys;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model.BusinessModel.OutPut.sys;
using Model.BusinessModel.OutPut;
using Utility;
using Model.BusinessModel.MatchFormula;
using Utility.Enum;

namespace OverallAuth_WebApi.Controllers.MatchFormula
{
    /// <summary>
    /// 匹配公式
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "MatchFormula")]
    public class MatchFormulaController : ControllerBase
    {
        #region 构造实列化

        /// <summary>
        /// 匹配公式服务
        /// </summary>
        public IMatchFormulaService _matchFormulaService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="matchFormulaService"></param>
        public MatchFormulaController(IMatchFormulaService matchFormulaService)
        {
            _matchFormulaService = matchFormulaService;
        }

        #endregion

        #region 接口实现

        /// <summary>
        /// 解析匹配公式
        /// </summary>
        /// <param name="matchFormula">匹配公式字符串</param>
        /// <param name="menuId">菜单id</param>
        /// <param name="ruleType">规则类型</param>
        /// <returns>返回解析字符串</returns>
        [HttpGet]
        public ReceiveStatus<AnalysisRuleDataOutPut> AnalysisMatchFormula(string matchFormula, string menuId, int ruleType)
        {
            return _matchFormulaService.AnalysisMatchFormula(matchFormula, menuId, ruleType);
        }

        /// <summary>
        /// 获取菜单数据按钮权限
        /// </summary>
        /// <param name="input">匹配数据按钮权限模型</param>
        /// <returns></returns>
        [HttpPost]
        public ReceiveStatus<SysButtonDataOutPut> GetMenuDataButtonAuth(MatchingDataButtonAuthInput input)
        {
            return _matchFormulaService.GetMenuDataButtonAuth(input);
        }

        /// <summary>
        /// 获取下拉框数据源
        /// </summary>
        /// <param name="showControlDataSourceEnum">数据源类型</param>
        /// <returns></returns>
        [HttpGet]
        public ReceiveStatus<SelectOutPut> GetSelectData(ShowControlDataSourceEnum showControlDataSourceEnum)
        {
            return _matchFormulaService.GetSelectData(showControlDataSourceEnum);
        }
        #endregion
    }
}
